package com.shtel.bss.saas.tenant.entity.repository.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.shtel.bss.saas.tenant.entity.SysTenant;
import com.shtel.bss.saas.tenant.mapper.SysTenantMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.shtel.bss.saas.tenant.entity.repository.ISysTenantRepository;

import java.util.List;

/**
 * sys_tenant仓库现实类
 * @author xiezhiwei 2020-02-05 21:21
 */
@Repository("sysTenantRepository")
public class SysTenantRepositoryImpl implements ISysTenantRepository {
    @Autowired
    private SysTenantMapper sysTenantMapper;

    @Override
    public PageInfo<SysTenant> selectEntity(SysTenant sysTenant,int pageSize, int pageNum) {
        PageHelper.startPage(pageNum, pageSize, true);
        PageInfo<SysTenant> pageInfo = new PageInfo(sysTenantMapper.selectEntity(sysTenant));
        return pageInfo;
    }

    @Override
    public SysTenant selectEntityByTenantId(Long tenantId) {
        return sysTenantMapper.selectByPrimaryKey(tenantId);
    }

    @Override
    public void updateEntity(SysTenant sysTenant) {
        sysTenantMapper.updateEntity(sysTenant);
    }

    @Override
    public PageInfo<SysTenant> selectEntityByAuthId(Long authId,int pageSize,int pageNum){
        PageHelper.startPage(pageNum, pageSize, true);
        PageInfo<SysTenant> pageInfo = new PageInfo(sysTenantMapper.selectEntityByAuthId(authId));
        return pageInfo;
    }

    @Override
    public PageInfo<SysTenant> selectEntityByAuthIdNot(Long authId,int pageSize,int pageNum) {
        PageHelper.startPage(pageNum, pageSize, true);
        PageInfo<SysTenant> pageInfo = new PageInfo(sysTenantMapper.selectEntityByAuthIdNot(authId));
        return pageInfo;
    }
}